package text;

// Supermarket.java - 超市管理
public class Supermarket {
    private Fruit apple;
    private Fruit strawberry;
    private Fruit mango;

    public Supermarket() {
        this.apple = new Apple();
        this.strawberry = new Strawberry();
        this.mango = new Mango();
    }

    // 1. 顾客A：只买苹果和草莓
    public double calculateForCustomerA(int appleWeight, int strawberryWeight) {
        ShoppingCart cart = new ShoppingCart();
        cart.addFruit(apple, appleWeight);
        cart.addFruit(strawberry, strawberryWeight);
        return cart.calculateTotalPrice();
    }

    // 2. 顾客B：购买苹果、草莓和芒果
    public double calculateForCustomerB(int appleWeight, int strawberryWeight, int mangoWeight) {
        ShoppingCart cart = new ShoppingCart();
        cart.addFruit(apple, appleWeight);
        cart.addFruit(strawberry, strawberryWeight);
        cart.addFruit(mango, mangoWeight);
        return cart.calculateTotalPrice();
    }

    // 3. 顾客C：草莓打8折
    public double calculateForCustomerC(int appleWeight, int strawberryWeight, int mangoWeight) {
        ShoppingCart cart = new ShoppingCart();
        cart.addFruit(apple, appleWeight);
        
        // 设置草莓8折
        Fruit discountedStrawberry = new Strawberry();
        discountedStrawberry.setDiscount(0.8);
        cart.addFruit(discountedStrawberry, strawberryWeight);
        
        cart.addFruit(mango, mangoWeight);
        return cart.calculateTotalPrice();
    }

    // 4. 顾客D：满100减10
    public double calculateForCustomerD(int appleWeight, int strawberryWeight, int mangoWeight) {
        ShoppingCart cart = new ShoppingCart();
        cart.addFruit(apple, appleWeight);
        cart.addFruit(strawberry, strawberryWeight);
        cart.addFruit(mango, mangoWeight);
        
        // 设置满100减10
        cart.setPromotion(100, 10);
        return cart.calculateTotalPrice();
    }

    // 获取水果对象（用于自定义购物）
    public Fruit getApple() { return apple; }
    public Fruit getStrawberry() { return strawberry; }
    public Fruit getMango() { return mango; }
}